package com.alstudio.utils.android.net.upload;

import com.alstudio.ui.base.BaseActivity;
import com.alstudio.utils.android.net.upload.ALHttpUploadTask.ALHttpUploadErrorCode;
import com.alstudio.utils.log.Mylog;

public class ALHttpUploadManager {

	public static void startUpload(BaseActivity context, String url, String path) {
		ALHttpUploadTask task = new ALHttpUploadTask(context, url, path,
				mListener);
		task.execute();
	}

	private static ALHttpUploadListener mListener = new ALHttpUploadListener() {

		@Override
		public void onUploadStart(ALHttpUploadTask task) {
			// TODO Auto-generated method stub
			Mylog.e("开始上传");
		}

		@Override
		public void onUploadFinish(ALHttpUploadTask task) {
			// TODO Auto-generated method stub
			Mylog.e("上传完成");

		}

		@Override
		public void onUpdateProgress(ALHttpUploadTask task) {
			// TODO Auto-generated method stub
			Mylog.e("上传速度改变: " + task.getUploadSpeed());
			Mylog.e("上传进度改变: " + task.getUploadPercent());

		}

		@Override
		public void onUploadFail(ALHttpUploadTask task,ALHttpUploadErrorCode code) {
			// TODO Auto-generated method stub
			Mylog.e("上传失败: " + code + " 响应码: " + task.getResponseCode());
		}
	};

}
